<template>
  <el-dialog
    title="定时任务设置"
    :visible="dialogVisible"
    width="40%"
    @open="open"
  >
    <el-form
      :model="form"
      :rules="rules"
      ref="ruleForm"
      label-width="auto"
      class="demo-ruleForm"
      size="small"
    >
      <el-form-item label="进度设置" prop="name1">
        <el-input v-model="form.name1" placeholder="请输入进度设置"></el-input>
      </el-form-item>
      <el-form-item label="时间设置" prop="name2">
        <el-input v-model="form.name2" placeholder="请输入时间设置"></el-input>
      </el-form-item>
      <el-form-item label="音响设置" prop="name3">
        <el-input v-model="form.name3" placeholder="请输入音响设置"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="close" size="small">取 消</el-button>
      <el-button type="primary" @click="sumbit" size="small">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  props: {
    dialogVisible: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      form: {
        name1: "",
        name2: "",
        name3: "",
      },
      rules: {
        name1: [{ required: true, message: "请输入进度设置", trigger: "blur" }],
        name2: [{ required: true, message: "请输入时间设置", trigger: "blur" }],
        name3: [{ required: true, message: "请输入音响设置", trigger: "blur" }],
      },
    };
  },
  methods: {
    open() {
      this.$nextTick(() => {
        this.$refs["ruleForm"].resetFields();
        this.$refs["ruleForm"].clearValidate();
      });
    },
    sumbit() {
      this.$refs["ruleForm"].validate((valid) => {
        if (valid) {
          this.$msg({
            type: "success",
            message: "提交成功",
          });

          this.close();
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    close() {
      this.$emit("update:dialogVisible", false);
    },
  },
};
</script>

<style>
</style>